<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<include file="Public/head" />
</head>

<body>
<include file="Public/top" />

<div class="page_minheight">
<div class="login_tit">
  <div class="return"><a href="{:U('User/login')}"><i class="icon-fanhui"></i></a></div>
  <span>忘记密码</span>
</div><!--login_tit-->

<div class="page_in margin">
  <form id="forget_pwd" action="{:U('User/identity')}" method="post">
    <div class="ginput_div ginput_div_icon"><i class="icon-shouji1"></i><input class="ginput" type="text" name="username" id="username" placeholder="手机号" onBlur="chkuser()" /></div>
    <input type="hidden" name="type" value="forget">
    <div class="ginput_div ginput_div_icon"><i class="icon-mima"></i><input class="ginput" onKeyDown="if(event.keyCode==13){checkSubmit();}" type="text" name="verify_code" id="captcha" placeholder="请输入验证码" maxlength="4" /><span class="code"><img id="verify_code_img" class="verify_code_img_reg" src="/index.php?m=Home&c=User&a=verify" onclick="verify()"  /></span></div>
    <div class="ginput_div"><button type="button" class="login_sub" onclick="chkcaptcha();">下一步</button></div>
  </form>
</div><!--page_in-->
</div><!--page_minheight-->

<script>
function verify()
{
	$('#verify_code_img').attr('src','/index.php?m=Mobile&c=User&a=verify&r='+Math.random());
}

var uflag = false;
var cflag = false;

function chkuser(){
	//$('span[data-tips-for="username"]').find('.txt').empty();
	var username = $('#username').val();
	if(username == ''){
		//show_error('username','用户名不能为空');
		layer.alert('用户名不能为空.', 800);
		return false;
	}else{
		$.ajax({
			url:'/index.php?m=Home&c=User&a=check_username&t='+Math.random(),
			type:'post',
			dataType:'json',
			data:{username:username},
			success:function(t){



				if(t==1){
					uflag = true;
				}else{
					layer.alert('用户名错误.', 800);
					$("#username").focus();
				}
			}
		})
	}
}

function chkcaptcha(){
	//$('span[data-tips-for="captcha"]').find('.txt').empty();
	var captcha = $('#captcha').val();
	if(captcha == ''){
		layer.alert('验证码不能为空.', 800);
		return false;
	}else if(captcha.length!=4){
		
		layer.alert('验证码错误.', 800);
		return false;
	}else{
		$.ajax({
			url:'/index.php?m=Home&c=User&a=check_captcha&t='+Math.random(),
			type:'post',
			dataType:'json',
			data:{verify_code:captcha},
			success:function(t){
				if(t==1){
					/*$('span[data-tips-for="captcha"]').css('display','inline');
					$('span[data-tips-for="captcha"]').find('i').removeClass('icon');
					$('span[data-tips-for="captcha"]').find('i').removeClass('icon-warn');
					$('span[data-tips-for="captcha"]').find('i').addClass('icon-loss');
					$('span[data-tips-for="captcha"]').find('.txt').empty();*/
					cflag = true;
					gonext();
				}else{
					layer.alert('验证码不正确.', 800);
					return false;
				}
			}
		})
	}
}

function gonext(){
	if($('#username').val() == ''){
		layer.alert('用户名不能为空.', 800);
		return;
	}
	if($('#captcha').val() == ''){
		layer.alert('验证码不能为空.', 800);
		return;
	}
/*	if(!uflag){
		layer.alert('用户名验证有误.', 800);
		return;
	}else if(!cflag){
		layer.alert('图形验证码有误.', 800);
		return;
	}
	if(uflag && cflag){
		$('#forget_pwd').submit();
	}*/

	$('#forget_pwd').submit();
}
</script>

<include file="Public/footer" />
<script src="__STATIC__/js/global_after.js" type="text/javascript"></script>
</body>
</html>